package com.java.Service;

import com.java.dao.HouseDAO;
import com.java.entity.House;
import com.java.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HouseService {
    @Autowired
    HouseDAO houseDAO;


    /*
       处理房天下数据
    * */
    public List<House> list(){
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        List<House> all = houseDAO.findAll(sort);
        for (House house : all) {
            house.setAddress(StringUtils.replaceBlank(house.getAddress()));
            house.setArea(StringUtils.replaceBlank(house.getArea()));
            house.setAvg_price(StringUtils.replaceBlank(house.getAvg_price()));
            house.setDescribe(StringUtils.replaceBlank(house.getDescribe()));
            house.setImg_url(StringUtils.replaceBlank(house.getImg_url()));
            house.setPrice(StringUtils.replaceBlank(house.getPrice()));
            house.setTitle(StringUtils.replaceBlank(house.getTitle()));

        }
        System.out.println(all);
        return all;
    }
}
